using UnityEngine;

namespace NodeCanvas.BehaviourTrees
{
	[AddComponentMenu("")]
	[Name("Remap")]
	[Category("Decorators")]
	[Description("Remap the child node's status to another status. Used to either invert the child's return status or to always return a specific status.")]
	[Icon("Remap")]
	public class BTRemapper : BTDecorator
	{
		public enum RemapStates
		{
			Failure = 0,
			Success = 1,
			Inactive = 3
		}

		public RemapStates successRemap = RemapStates.Success;

		public RemapStates failureRemap;

		protected override Status OnExecute(Component agent, Blackboard blackboard)
		{
			if (!base.decoratedConnection)
			{
				return Status.Resting;
			}
			base.status = base.decoratedConnection.Execute(agent, blackboard);
			if (base.status == Status.Success)
			{
				if (successRemap == RemapStates.Inactive)
				{
					base.decoratedConnection.ResetConnection();
				}
				return (Status)successRemap;
			}
			if (base.status == Status.Failure)
			{
				if (successRemap == RemapStates.Inactive)
				{
					base.decoratedConnection.ResetConnection();
				}
				return (Status)failureRemap;
			}
			return base.status;
		}
	}
}
